/***
 * 会签策略
 * @param {Object} e
 */


var signStore = Ext.create('Ext.data.Store', {
    autoLoad: true,
    fields: ['signValue', 'sign'],
    data:[
		{
            "sign": "一票否决制",
            "signValue": 1
        },
        {
            "sign": "一票通过制",
            "signValue": 2
        },
        {
            "sign": "意见收集制",
            "signValue": 3
        },
        {
            "sign": "比例通过制",
            "signValue": 4
        }
    ]
});
var signPanel = Ext.create('Ext.form.Panel', {
	id: 'signs',
	border: false,
	bodyStyle: {background:"#dfe7f4",padding:"10 0 0 20"},
	labelAlign: 'right',
	bodyPadding: 5,
	layout : 'column',
	fieldDefaults: {
		labelAlign: 'right',
		labelWidth: 90,
		anchor: '30%'
 	},
	items:[{  
        columnWidth:.5,//指定列宽为容器宽度的50%  
        layout : 'form',
        height : 100 ,
        frame : true,
        items : [{
			fieldLabel: '策略类型',
			xtype: 'combo',
			emptyText: '请选择',
			id: 'sign',
			border: false,
			displayField: 'sign',
	    	valueField: 'signValue',
			store : signStore,
			listeners:{
				select:function(r){
					if(curXmlNode != null){					
						curXmlNode.setAttribute("sign", r.getValue());
					} 
				}
			}
		},{
			xtype:'field',
			fieldLabel: '策&nbsp; 略&nbsp;值',
			id: 'signValue',
			enableKeyEvents: true,
			width:200,
			listeners: {
				'keyup': function(e){
 					if(curXmlNode != null){
						curXmlNode.setAttribute("signValue", e.getValue());
					}
					
				}
			}
		}]
    }]
});
Ext.override(Ext.form.RadioGroup, {
	getValue : function() {
		var v;
		if (this.rendered) {
			this.items.each(function(item) {
				if (!item.getValue())
					return true;
				v = item.getRawValue();
				return false;
			});
		} else {
			for ( var k in this.items) {
				if (this.items[k].checked) {
					v = this.items[k].inputValue;
					break;
				}
			}
		}
		return v;
	},
	setValue : function(v) {
		if (this.rendered)
			this.items.each(function(item) {
				item.setValue(item.getRawValue() == v);
			});
		else {
			for ( var k in this.items) {
				this.items[k].checked = this.items[k].inputValue == v;
			}
		}
	}
});
function setSign(){

	if(curXmlNode != null){
		
		Ext.getCmp("sign").setValue(curXmlNode.getAttribute("sign"));
		
		var sign = curXmlNode.getAttribute("sign");

		if(sign != null){
			Ext.getCmp("signRadioGroup").setValue(sign);
			//obj[sign].checked = true;
		}
		var signValue = curXmlNode.getAttribute("signValue");
		//obj[].checked = true;
		//Ext.getCmp("baseName").setValue();
		if(signValue != null){
			Ext.getCmp("signValue").setValue(signValue);
		}
		
		
	}
	
}